﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using System.Threading;

namespace SignalRWebChat
{
    public class ChatHub : Hub
    {
        static Boolean started = false;
        public void Send(string name, string message)
        {
            // Call broadcastMessage method to update clients.
            Clients.All.broadcastMessage(name, message);
            if (started == false)
            {
                started = true;
                Thread myTime = new Thread(serverTime);
                myTime.Start();
            }

        }
        public void serverTime()
        {
            while(true)
            {
                Clients.All.broadcastMessage("System Time ", DateTime.Now.ToString());
                Thread.Sleep(10000);
            }
        }
    }

}